<!DOCTYPE html>
<html lang="zh-CN">
<head>

<#include "bases/global_style.ftl"> 
<#include "bases/global_js.ftl">
<#include "bases/combo.ftl">


<script>
	var curent_page=${currentpage};

	var dataform;
	jQuery(document).ready(function()
	{
		var optInit = getOptionsFromForm();
		$("#Pagination").pagination(${totalRecord}, optInit);
		App.init();
		dataform=$("#dataform").validate();
	});
	
	function doDownloadExcel(){
		
		$("#searchform #export").val("true");
		$("#searchform").submit();

	}
	
    function doDeleteTableRow(id){

	 
		jConfirm('确定删除该记录?', '提示', function(r) {
			  if(r==true){
				$("#searchform").attr("action","${base}/del_trade_abnormal_general?id="+id);
		    	$("#searchform").submit();
			  }
		});
		 
    }
    
    function  setCompanyInfo(id){
    	
		$.ajax({
			type : "POST",
    		url : CONTEXT+'/get_company_byexchageid_general?id='+id,
    		dataType : "json",  
  	      	success : function(data) {
  	      		
  	      	  $("#dataform #accountName").val(data.accountName);
  	          $("#dataform #account").val(data.account);
  	          $("#dataform #balance").val(data.fare/100);
  	          $("#dataform #accountid").val(data.accountid);
  	          $("#dataform #personName").val(data.personName);
  	      	}
		});
    }
    
    
    function addEntity(){
  	    
    	dataform.form();
	    if(dataform.valid()){
            var a ;
            var nowtime = new Date();
            var strtemp = ""+nowtime.getHours()+nowtime.getMinutes()+nowtime.getSeconds()+nowtime.getMilliseconds();
            a=strtemp;

            $("#amount_deci").val($("#amount_deci").val()*100);
            $("#loading").showLoading(); 
    		$.ajax({  
      		      type : "POST",  
      		      url :  "${base}/add_trade_abnormal_general/" + a,
      		      data:  $("#dataform").serialize(),
      		      dataType : "json",  
      		      success : function(data) {  
	      		       	    $('#loading').hideLoading();
		      		        if(data.result ==true) {
	                            window.location.reload();
	      		       		}else{
                        		jAlert(data.msg);
                        	}
                        	
      		      }  
  		    }); 
            
	    }
	 }
    
	function showAddDiv(){
		
		 combox("execChargid","CompanySerialNum",null,null,false);
		 $("#execChargid").chosen({
			 
			 no_results_text: "没有找到"
		 
		 }).change(function(){
			 setCompanyInfo($('#execChargid option:selected').val());
			 $("#chargeid").val($('#execChargid option:selected').val());
		 }); 
		 showPopup("addDiv"); 
	}

 

	function showPopup(div) 
    {//弹出层
        var backDiv = document.getElementById("backDiv");
        backDiv.style.top = "0%";//设置弹出层距离上边界的距离
        backDiv.style.left = "0%";//设置弹出层距离左边界的距离
        backDiv.style.width = "100%";//设置弹出层的宽度
        backDiv.style.height = "100%";//设置弹出层的高度
        backDiv.style.visibility = "visible";

        var addDiv = document.getElementById(div);
        addDiv.style.top = "10%";//设置弹出层距离上边界的距离
        addDiv.style.left = "30%";//设置弹出层距离左边界的距离
        addDiv.style.width = "40%";//设置弹出层的宽度
        addDiv.style.height = "auto";//设置弹出层的高度
        addDiv.style.visibility = "visible";

    }

	function hidePopup() 
    {//关闭层
        var backDiv = document.getElementById("backDiv");
        backDiv.style.visibility = "hidden";

        var addDiv = document.getElementById("addDiv");
        addDiv.style.visibility = "hidden";
    }

	function allDivHide() 
    {
        hidePopup();
        $("input[name=status]").val(["0"]);
    }

</script>
</head>

<body>

	<div id="backDiv" onclick="allDivHide()" style="position: absolute;visibility: hidden;position:fixed;overflow: hidden;solid: #000000;background-color: #000000;padding: 1px;z-index: 99;filter:alpha(opacity=50);opacity: 0.5;"></div>

	<!-- 添加公司交易异常 -->
	<div id="addDiv" class="row-fluid" style="position: absolute;visibility: hidden;overflow: hidden;padding: 1px;z-index: 100;background-color: #FFFFFF;">
		<div class="span12">
        <div class="portlet box green" style="margin: -1px;">
            <div class="portlet-title">
                <div class="caption"><i class="fa fa-edit"></i>添加公司换电记录退款</div>
                <a href="javascript:hideEditTable();" class="remove"></a>
            </div>
            
            <div class="portlet-body flip-scroll">
            	<form id="dataform" method="POST">
            	
            	<input type="hidden" name="accountid" id="accountid">
            	<input type="hidden" name="type" id="type" value="1">
                <input type="hidden" name="status" id="status" value="2">
            	
            	<table class="table-bordered table-striped table-condensed flip-content">
            		<tbody role="alert" aria-live="polite" aria-relevant="all">
         
            		<tr class="even">
            			<td style="text-align: right;">搜索流水号<span class="fill-must">*</span></td>
            			<td class="even">
	            			   <select     style="margin-top: 10px;width: 240px;height: 40px" id="execChargid" required>
							    </select>
							    <input type="hidden" id="chargeid" name="execChargid">
            			</td>
            		</tr>
            		<tr class="odd">
            			<td style="text-align: right;">账号</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="account" name="account"  readonly />
            			</td>
            		</tr>
            		<tr class="odd">
            			<td style="text-align: right;">所属公司</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="accountName"  readonly/>
            			</td>
            		</tr>
            		<tr class="even">
            			<td style="text-align: right;">换电费用</td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="balance" readonly/>
            			
            			</td>
            		</tr>
                    <tr class="odd">
            			<td style="text-align: right;">对应个人<span class="fill-must">*</span></td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="personName" readonly/>
            			</td>
            		</tr>
            	    <tr class="even">
            			<td style="text-align: right;">退款金额<span class="fill-must">*</span></td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="number" id="amount_deci" name="amount" required placeholder="请输入异常金额"/>
            			</td>
            		</tr>
            		 <tr class="odd">
            			<td style="text-align: right;">退款理由<span class="fill-must">*</span></td>
            			<td class="even">
            				<input class="m-wrap span8" style="margin-top: 10px" type="text" id="reason" name="reason" required placeholder="请输入异常理由不超过20个字"/>
            			</td>
            		</tr>
            		</tbody>
            		</table>
            		<div class="controls controls-row" style="text-align: right;">
                        <input type="button" value="保存" class="btn green" onclick="addEntity()"/>
                        <input type="button" value="取消" class="btn green" onclick="allDivHide()" />
                    </div>
            	</form>
            </div>
        </div>
        </div>
	</div>
 
<#include "bases/navhead.ftl"> 
<#include "bases/sidebar.ftl">

	<div class="page-container secMenu-content" id="loading">

		<div class="page-content">

			<div class="container-fluid">

				<div class="row-fluid">
					<div class="span12">
						<div class="portlet box green">
							<div class="portlet-title">
								<div class="caption">
									<i class="fa fa-cogs"></i>换电记录退款
								</div>
	                            <div class="tools">
	                                <a href="javascript:window.location.reload()" class="reload"></a>
	                            </div>
							</div>
							
							<div class="portlet-body flip-scroll">
								<a class="btn page-role" onclick="window.location.href='<@spring.url '/trade_abnormal_general?task=person'></@spring.url>'">个人类型账户</a>
	  							<a class="btn page-role page-now list-headBtn" onclick="window.location.href='<@spring.url '/trade_abnormal_general?task=company'></@spring.url>'">公司类型账户</a>
							</div>

							<!-- 公司账户 -->
							<div class="portlet-body flip-scroll">
								<form id="searchform" action="<@spring.url '/trade_abnormal_general'></@spring.url>" method="POST">
							
									<div class="controls controls-row">
									
	                                    <label for="tel">所属公司：</label>
	                                    <select id="accountid" name="accountid" class="form-control sheet-searchInput">
		                                    <option value="">===请选择===</option>
			                                <#if companyList??>
				                                <#list companyList as clist> 
				                                    <option value="<#if clist.getKey()??>${clist.getKey()}</#if>" <#if accountid??><#if accountid=="${clist.getKey()}">selected="selected"</#if></#if>><#if clist.getValue()??>${clist.getValue()}</#if></option>
				                                </#list>
			                                  </#if>
		                                </select>
	                                  
                                        <label for="">发生日期：</label>
                                        <input  name="begindate" type="text" class="form-control sheet-searchInput" id="begindate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  value="<#if begindate??>${begindate}</#if>"/>
                                   
                                        <label for="">至：</label>
                                        <input  name="enddate" type="text" class="form-control sheet-searchInput" id="enddate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  value="<#if enddate??>${enddate}</#if>"/>
                                        
                                        <label for="">审核状态：</label>
                                        <select name="status" class="form-control sheet-searchInput" value="${status!}">
											<option value="">===请选择===</option>
				  							<#if statusList??>
	                                			<#list statusList as slist> 
	                                    			<option value="${slist.getKey()}" <#if (status!'')=="${slist.getKey()}">selected="selected"</#if>><#if slist.getValue()??>${slist.getValue()}</#if></option>
	                                			</#list>
                                  			</#if>
										</select>
                                   		
                                   		<input type="hidden" id="currentpage" name="page" value="0" />
                                   		<input type="hidden" id="task" name="task" value="company" />
                                   	    <input type="hidden" id="export" name="export" value="" />
								        <input  type="hidden" id="postsortfield" name="sortfield" value="<#if sortfield??>${sortfield}</#if>" />
										<button type="submit" class="btn blue">搜索</button>
									
									</div>
	                                <div class="controls controls-row" style="margin-top: 20px">
	                                
	                                    <button type="button" class="btn green" onclick="doDownloadExcel()">导出</button>
	 
	                                </div>
									<table class="table table-bordered table-hover table-striped table-condensed list-table">
										<thead class="flip-content">
											<tr>
											    <th style="text-align: center;">日期</th>
									            <th style="text-align: center;">流水号</th>
									            <th style="text-align: center;">账号</th>
									            <th style="text-align: center;">所属公司</th>
									            <th style="text-align: center;">手机号</th>
									            <th style="text-align: center;">申请退款金额</th>
									            <th style="text-align: center;">退款理由</th>
									            <th style="text-align: center;">状态</th>
									            <th style="text-align: center;">不通过理由</th>
									            <th style="text-align: center;">操作员</th>
									            <th style="text-align: center;width: 100px">操作</th>
											</tr>
										</thead>
										<tbody>
											<#list companyInfoList as item>
											<tr>
												<#if item??>
												<td style="text-align: center;"><#if item.getCreatedate()??>${item.getCreatedate()}</#if></td>
												<td style="text-align: center;"><#if item.getSerialNum()??>${item.getSerialNum()}</#if></td>
												<td style="text-align: center;"><#if item.getAccount()??>${item.getAccount()}</#if></td>
												<td style="text-align: center;"><#if item.getAccountName()??>${item.getAccountName()}</#if></td>
												<td style="text-align: center;"><#if item.getTel()??>${item.getTel()}</#if></td>
												<td style="text-align: center;"><#if item.getAmount()??>${item.getAmount()/100}</#if></td>
												<td style="text-align: center;"><#if item.getReason()??>${item.getReason()}</#if></td>
												<td style="text-align: center;"><#if item.getStatusName()??>${item.getStatusName()}</#if></td>
												<td style="text-align: center;"><#if item.getCheckreason()??>${item.getCheckreason()}</#if></td>
												<td style="text-align: center;"><#if item.getOpername()??>${item.getOpername()}</#if></td>
												<td style="text-align: center;"> 
										         	<a  onclick="javascript:doDeleteTableRow('${item.getId()}')" class="bianji">删除</a>
												</td> 
												</#if>
											</tr>
											</#list>
										</tbody>
									</table>
									<div class="controls controls-row">
										<div id="Pagination" class="pagination"></div>
									</div>
								</form>
							</div>
							
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
</body>